package com.lcy.proto.server;

import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.lcy.proto.rpc.MathService;
import com.lcy.proto.rpc.Params;
import com.lcy.proto.rpc.Result;

/**
 * @author loucy
 * @version 1.0
 */
public class ServerMathService extends MathService {
    @Override
    public void add(RpcController controller, Params request, RpcCallback<Result> done) {
        Result.Builder builder = Result.newBuilder();
        done.run(builder
                .setResult(request.getParam1()+request.getParam2())
                .build());
    }

    @Override
    public void sub(RpcController controller, Params request, RpcCallback<Result> done) {
        Result.Builder builder = Result.newBuilder();
        done.run(builder
                .setResult(request.getParam1()-request.getParam2())
                .build());
    }
}
